package com.zhoushihao.class0811;

import java.util.Random;

public class GetPI {
    public static void main(String[] args) {
        Circle circle = new Circle(new Point(1,1),1);
        double Area = Math.pow(circle.radius*2,2);
        double startX = circle.center.x-circle.radius;
        double startY = circle.center.y-circle.radius;
        Random random = new Random();
        int count = 0;
        int num = 100000000;
        for (int i = 0; i < num; i++) {
            Point p = new Point(startX+random.nextDouble()*2*circle.radius,startY+random.nextDouble()*2*circle.radius);
            if(circle.isPointInCircle(p)){
                count++;
            }
        }
        System.out.println(count*1.0/num*Area);
    }
}
